﻿using System;
using System.Windows;
using System.Windows.Data;

namespace AnthStat.WPF.Applications.Converters
{
    public sealed class MessageBoxButtonConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var desiredButtonSet = (MessageBoxButton) value;

            var actualButtonSet = parameter.ToString();

            if (
                (desiredButtonSet == MessageBoxButton.OK && actualButtonSet.Equals("OK", StringComparison.OrdinalIgnoreCase)) ||
                (desiredButtonSet == MessageBoxButton.OKCancel && actualButtonSet.Equals("OKCancel", StringComparison.OrdinalIgnoreCase)) ||
                (desiredButtonSet == MessageBoxButton.YesNo && actualButtonSet.Equals("YesNo", StringComparison.OrdinalIgnoreCase)) ||
                (desiredButtonSet == MessageBoxButton.YesNoCancel && actualButtonSet.Equals("YesNoCancel", StringComparison.OrdinalIgnoreCase))
                        )
            {
                return Visibility.Visible;
            }

            return Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
